from config import *
from 绘图 import get_plot_show
# 获取增长因子
# 359 0.01942797193984025
# 360 0.01937348593887278
q = math.pow(1000,1/360) - 1
print("增长因子",q)

def weight(q,day):
    '''
    :param q: 增长系数
    :param day: day天后
    :return:day天后一条鱼的重量
    '''
    return 1.0/500 * pow(q+1, day)

def weight_day(w):
    '''
    :param w: 重wkg
    :return: 一条鱼多少天后达到wkg
    '''
    return 360*math.log(500*w,1000)

def food_cost_day(w):
    # 养殖wkg需要多少费用
    '''
    :param w: 重量
    :return:  那么返回一天w公斤鱼的成本,饲料费用
    '''
    return w * 0.05 * 0.5

def get_money(w):
    '''
    :param w:
    :return:返回w重量的收益
    '''
    if w < 0.2:
        return 0
    if 0.2<=w and w<0.75:
        return 12
    if 0.75<=w and w<1.5 :
        return 16
    if 1.5<=w and w<=2.0 :
        return 20
    return

# print(0.2,weight_day(0.2))
# print(0.75,weight_day(0.75))
# print(1.5,weight_day(1.5))
# print(2,weight_day(2))

'''
0.2 240.00000000000003
0.75 308.88375212732626
1.5 345.007351607004
2 360.0
'''

'''单条鱼的增长曲线图'''
# x = np.arange(1,361,1)
# y = weight(q,x)
# get_plot_show(x,y,xlabel=r'天数',ylabel=r'单条鱼的重量')

'''单条鱼增长的饲料费用'''
# x = np.arange(0,360,1)      #天数
# y = weight(q,x)             #单条鱼的重量
# cost = food_cost_day(y)     #
# cost_ans = [0]
# for i in cost :
#     cost_ans.append(i+cost_ans[-1])
# get_plot_show(x,cost_ans[1:],xlabel=r'天数',ylabel=r'饲料费用',title=r'单条鱼增长的饲料费用',label_name=None)

'''如果在第k天卖掉单条鱼，那么收益是'''
# x = np.arange(1,361,1)      #天数
# def get_money2(k):
#     x = np.arange(1,k+1,1)      #天数
#     y = weight(q,x)             #每一天 单条鱼的重量
#     if y[-1]>2:
#         y[-1]=2
#     inputs = get_money(y[-1])   #最后一天的价格
#     cost = food_cost_day(y)
#     cost_ans = [0]
#     for i in cost :
#         cost_ans.append(i+cost_ans[-1])
#     if inputs is None:
#         print(1)
#     earn = inputs-cost_ans[-1]
#     return earn
# ans = []
#
# for k in range(1,361):
#     ans.append(get_money2(k))
# get_plot_show(x,ans,xlabel=r'天数',ylabel=r'收益',title=r'单条鱼随时间的收益',label_name=None)

